load("analytic_c2_pop.RData")



### TABLE 1 (& A1 & A3): Researcher Publications

# Number of experienced researchers:

N_auth_exp

###

# A) Current Publications

# Number of articles:

round( rbind(
       table(authorcounts[exper_auth])   / length(authorcounts[exper_auth]) ,
cumsum(table(authorcounts[exper_auth]) ) / length(authorcounts[exper_auth])
),3)

# Unfamiliar topics:

# NOTE: See alternative method in 'robustness.R'.
# (that uses all papers, this uses top three)

round(rbind(
	sum( obs_shares[rowSums(dif_t, na.rm=T) ==0] ),
	sum( obs_shares[rowSums(dif_t, na.rm=T) > 0] )
), 3)

###

# B) Prior Publications

# Restrict to experienced authors:

temp <- authors[names(authorcounts)[exper_auth], ]

attach(temp)

# Prior period papers and impact:

round(rbind(
	mean(pre_experience),
	sd(pre_experience)
), 2)

round(rbind(
	mean(pre_avg_impact),
	sd(pre_avg_impact)
), 2)
 
detach(temp)



### TABLE 2: Distributions of Topics and Skills

# A) Paper Topics

# Number of articles:

nrow(articles)

# Distribution of topical areas:

attach(articles)

round(cbind(
	colMeans(cbind(bzfin,macro,apmic,agloc,methy) ),
	colMeans(cbind(bzfin > 0, macro > 0, apmic > 0, agloc > 0, methy > 0) )
), 3)

detach(articles)

###

# B) Researcher Skills

# Number of experienced researchers:

N_auth_exp

# Restrict to experienced authors:

temp <- authors[names(authorcounts)[exper_auth], ]

attach(temp)

# Distribution of areas of specialization,
# and proportions of codes conditional on specialization:

round(cbind(
  colMeans(cbind(bzfin > 0.5, macro > 0.5, apmic > 0.5, agloc > 0.5, methy > 0.5) ),
  rbind(
    mean(bzfin[bzfin > 0.5]),
    mean(macro[macro > 0.5]),
    mean(apmic[apmic > 0.5]),
    mean(agloc[agloc > 0.5]),
    mean(methy[methy > 0.5])
  )
), 3)

detach(temp)



### TABLE 3 (& A2 & A4): Project and Team Characteristics

attach(articles)

# Number of articles:

nrow(articles)

###

# A) Discrete Measures

# Number of authors:

round(cbind(
	table(num_authors)/nrow(articles)
), 3)

# Skill differences:

round(rbind( 
	table(skill_diff), table(skill_diff & any_gen50) ) / nrow(articles)
, 3)

### B) Continuous Measures

# Impact score (raw and residualized):

round(rbind( 
	cbind(mean(impact), sd(impact) ),
	cbind(mean(impact_res), sd(impact_res) )
), 2)

# External links and projects:

round(rbind(
	cbind(mean(team_deg), sd(team_deg) ),
	cbind(mean(tot_proj), sd(tot_proj) )
), 2)

# Skill deficit:

round(cbind(
	mean(skill_deficit),
	sd(skill_deficit)
), 3)

round(rbind(
	mean(skill_deficit == 0),
	mean(skill_deficit == 1)
), 3)

detach(articles)



### TABLE A5: Characteristics of Projects, by number of current projects

# Lists of papers by authors with each number of projects:

temp1 <- (unlist(paperlist[names(authorcounts[exper_auth & authorcounts == 1] ) ] ) )
temp2 <- (unlist(paperlist[names(authorcounts[exper_auth & authorcounts == 2] ) ] ) )
temp3 <- (unlist(paperlist[names(authorcounts[exper_auth & authorcounts == 3] ) ] ) )
temp4 <- (unlist(paperlist[names(authorcounts[exper_auth & authorcounts >  3] ) ] ) )

# Number of authors:

round(rbind(
	table(articles[temp1,]$num_authors) / length(temp1),
	table(articles[temp2,]$num_authors) / length(temp2),
	table(articles[temp3,]$num_authors) / length(temp3),
	table(articles[temp4,]$num_authors) / length(temp4)
), 3)

# Skill differences and generalists:

round(rbind(
	colMeans(cbind(
		articles[temp1,]$skill_diff,
		articles[temp1,]$skill_diff & articles[temp1,]$any_gen50 
	) ),
	colMeans(cbind(
		articles[temp2,]$skill_diff,
		articles[temp2,]$skill_diff & articles[temp2,]$any_gen50 
	) ),
	colMeans(cbind(
		articles[temp3,]$skill_diff,
		articles[temp3,]$skill_diff & articles[temp3,]$any_gen50 
	) ),
	colMeans(cbind(
		articles[temp4,]$skill_diff,
		articles[temp4,]$skill_diff & articles[temp4,]$any_gen50 
	) )
), 3)

# Impact score:

names(impact_res) <- rownames(articles)

round(cbind(
rbind(
	mean(articles[temp1,]$impact),
	mean(articles[temp2,]$impact),
	mean(articles[temp3,]$impact),
	mean(articles[temp4,]$impact)
),
rbind(
	mean(impact_res[temp1]),
	mean(impact_res[temp2]),
	mean(impact_res[temp3]),
	mean(impact_res[temp4])
) ), 3)

# Team degree, total projects, and skill deficit:

round(rbind(
	colMeans(cbind(
		articles[temp1,"team_deg"],
		articles[temp1,"tot_proj"], 
		articles[temp1,"skill_deficit"] 
	) ),
	colMeans(cbind(
		articles[temp2,"team_deg"],
		articles[temp2,"tot_proj"], 
		articles[temp2,"skill_deficit"] 
	) ),
	colMeans(cbind(
		articles[temp3,"team_deg"],
		articles[temp3,"tot_proj"], 
		articles[temp3,"skill_deficit"] 
	) ),
	colMeans(cbind(
		articles[temp4,"team_deg"],
		articles[temp4,"tot_proj"], 
		articles[temp4,"skill_deficit"] 
	) )
), 3)
